#!/usr/bin/env python
#-*-encoding:utf-8-*-
'''
Created on 2015年3月6日

@author: chenyongbing
'''
import sys,os,datetime
#current_dir = os.path.dirname(__file__)
current_dir = os.path.split(os.path.realpath(__file__))[0]




"""
Demonstrates how to use the blocking scheduler to schedule a job that executes on 3 second intervals.
"""


import os

import logging

from mysqlalchemy import SQLAlchemyJobStore
#from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.schedulers.base import BaseScheduler
from apscheduler.schedulers.blocking import BlockingScheduler
myJobStore = SQLAlchemyJobStore(url='mysql://root:zhimatech@localhost/scheduler')

def tick():
    print('Tick! The time is: %s' % datetime.datetime.now())


if __name__ == '__main__':
    scheduler = BlockingScheduler()
    
    #myjob = scheduler.add_job(tick, 'interval', seconds=3)
    #print scheduler.get_jobs()
    #print myjob
    #myJobStore.add_job(myjob)
    #print myJobStore.get_all_jobs()
    scheduler.add_jobstore(myJobStore, 'mysql')
    print scheduler.get_jobs()
    #scheduler.add_job(tick, 'interval', seconds=3,executor='',jobstore='mysql',name='我的时钟')
    scheduler.add_job(os.popen('python funcs.py'), 'interval', seconds=3,jobstore='mysql',name='我的时钟')
    print scheduler.get_jobs()
    scheduler.start()
    
    
#     
#     sys.exit()
#     print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
# 
#     try:
#         scheduler.start()
#     except (KeyboardInterrupt, SystemExit):
#         pass
    




